<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="java.util.*,org.lianqiao.tjut.bean.*" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%-- <%@ include file="inc.jsp" %> --%>
<jsp:include page="inc.jsp"></jsp:include>
</head>
<body>
<%
   //构造froeach标签需要解析的数据
   //将数据缓存在session对象中
   //数据结构是 list + entity 表示查询结果的二维表结构
   List lstDept = new ArrayList();

  DepartmentEntity dept1 = new DepartmentEntity();
  dept1.setDepartment_id(12);
  dept1.setDepartment_name("维修部");
  dept1.setLocation_id(101);
  lstDept.add(dept1);
  
  DepartmentEntity dept2 = new DepartmentEntity();
  dept2.setDepartment_id(13);
  dept2.setDepartment_name("开发部");
  dept2.setLocation_id(102);
  lstDept.add(dept2);
  
  DepartmentEntity dept3 = new DepartmentEntity();
  dept3.setDepartment_id(14);
  dept3.setDepartment_name("设计部");
  dept3.setLocation_id(103);
  lstDept.add(dept3);
  
  //将该数据放入session缓存中
  //session.setAttribute("lstDept222", lstDept);
  //session.removeAttribute("lstDept");
  request.setAttribute("lstDept222", lstDept);
  
  List lstMaps = new ArrayList();
  Map map1 = new LinkedHashMap();
  map1.put("name", "小明");
  map1.put("age",20);
  lstMaps.add(map1);
  
  Map map2 = new LinkedHashMap();
  map2.put("name","小张");
  map2.put("age",19);
  lstMaps.add(map2);
  
  session.setAttribute("lstMaps", lstMaps);
%>

   <br/>
	<!-- items 是foreach标签遍历的集合对象，一般使用el表达式从缓存中获取
	     var 是当前本次遍历获取的值存在以var属性值为名字的一个变量中
	     varStatus记录与遍历相关的一些数据信息，例如当前遍历的第几行，奇数行，偶数行
   <c:forEach items="${sessionScope.lstDept222}" var="eachVal" varStatus="statu">
      <c:out value="${statu.index + 1 }"></c:out>
      <c:out value="${eachVal.department_id}"></c:out>
      <c:out value="${eachVal.department_name}"></c:out>
      <c:out value="${eachVal.location_id}"></c:out><br>
      
   </c:forEach>
   <c:out value="${lstDept222[1].department_name }"></c:out>
	 -->
 <div class="bs-example">
    <table class="table table-bordered table-hover">
      <thead>
        <tr>
          <th>#</th>
          <th>部门ID</th>
          <th>部门名称</th>
          <th>地址编号</th>
        </tr>
      </thead>
      <tbody>
      <c:forEach items="${requestScope.lstDept222}" var="eachVal" varStatus="statu">
		<tr>
          <td >${statu.index + 1 }</td>
          <td>${eachVal.department_id }</td>
          <td>${eachVal.department_name }</td>
          <td>${eachVal.location_id }</td>
        </tr>		
	</c:forEach> 
	
	<br>
	<c:forEach items="${sessionScope.lstMaps}" var="val" varStatus="st">
	<!-- count总次数 -->
	<c:out value="${st.count}"></c:out>
	<br>
	<c:forEach items="${val}" var="each" varStatus="st2">
	<br>
	<c:out value="${each.key}"></c:out>
	      <c:out value="${each.value}"></c:out>
	</c:forEach>
	<br>
	</c:forEach>
	<br>
    单独输出：
  <c:out value="${sessionScope.lstMaps[0].keyset"></c:out>
      </tbody>
    </table>
  </div>
</body>
</html>


